//
//  AppNetworkingManager+Main.m
//  OANetworkManager
//
//  Created by TFAppleWork-Summer on 2018/2/7.
//  Copyright © 2018年 GuoRui. All rights reserved.
//

#import "AppNetworkingManager+Main.h"
#import "OAAuthTokenRequest.h"
@implementation AppNetworkingManager (Main)

+(TFRequest *)authTokenWithLoginName:(NSString *)loginName
                               completion:(OANetworkingObjectBlock)completion{
    
    OAAuthTokenRequest *request = [[OAAuthTokenRequest alloc] init];
    [request startRequestWithResponseBlock:^(__kindof TFRequest * _Nonnull request, id  _Nullable response, NSError * _Nullable error) {
        
        NSString *token = nil;
        if (error == nil) {
            token = [[response objectForKey:@"data"] objectForKey:@"auth_token"];
        }
        if (completion) {
            completion(token,error);
        }
    }];
    return request;
}

+(AppBaseRequest *)signWithToken:(NSString *)token
                        complete:(OANetworkingObjectBlock)complete{
    return [self startRequestWithParams:@{@"token" :token}
                                   path:@"attendance/sign"
                     responseObjectPath:@"data"
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:complete];
}

+ (AppBaseRequest *)getSignStateComplete:(OANetworkingObjectBlock)complete{
    return [self startRequestWithParams:nil
                                   path:@"attendance/isSign"
                     responseObjectPath:@"data"
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:complete];
}

@end
